//
//  MineViewController.m
//  CarLife
//
//  Created by yu on 2019/3/28.
//  Copyright © 2019年 jpas. All rights reserved.
//

#import "MineViewController.h"
#import "MineCell.h"
#import "MineAttentionViewController.h"
//#import "MineFansViewController.h"
#import "MineLikeViewController.h"
#import "MineLikedViewController.h"
#import "UserProfileViewController.h"
#import "MineCollectionViewController.h"
#import "FeedbackViewController.h"
#import "MineSettingViewController.h"



@interface MineViewController ()<UITableViewDelegate,UITableViewDataSource>

@property (weak, nonatomic) IBOutlet UITableView *tableView;

@end

@implementation MineViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    [self setRightNormalImageNamed:@"message" selectImageNamed:nil action:@selector(messageAction:)];
}

- (void)messageAction:(UIButton *)messageBtn
{
    
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 3;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 2;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    MineCell *cell = [MineCell initTableViewCellWith:tableView indexPath:indexPath];
    @weakify(self);
    [cell setHandleBlock:^(MineHandleType handleType) {
        @strongify(self);
        switch (handleType) {
            case MineHandleTypeAttention:{
                MineAttentionViewController *att = [[MineAttentionViewController alloc] init];
                att.mineFocusType = MineFocusTypeAttention;
                [self.navigationController pushViewController:att animated:YES];
            }
                break;
            case MineHandleTypeFans:{
                MineAttentionViewController *att = [[MineAttentionViewController alloc] init];
                att.mineFocusType = MineFocusTypeFans;
                [self.navigationController pushViewController:att animated:YES];
            }
                break;
            case MineHandleTypeLiked:
                [self.navigationController pushViewController:[MineLikedViewController new] animated:YES];
                break;
            default:
                break;
        }
        
    }];
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.section == 0) {
        if (indexPath.row == 0) {
            [self.navigationController pushViewController:[UserProfileViewController new] animated:YES];
        }
    } else if (indexPath.section == 1) {
        if (indexPath.row == 0) {
            [self.navigationController pushViewController:[MineCollectionViewController new] animated:YES];
        } else {
            [self.navigationController pushViewController:[MineLikeViewController new] animated:YES];
        }
    } else {
        if (indexPath.row == 0) {
            [self.navigationController pushViewController:[FeedbackViewController new] animated:YES];
        } else {
            [self.navigationController pushViewController:[MineSettingViewController new] animated:YES];
        }
    }
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (!indexPath.section) {
        if (!indexPath.row) {
            return 90;
        }
        return 60;
    } else {
        return 55;
    }
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 10;
}

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
    return 0.001;
}

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    [self setWhiteNavigationBar];
}

- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
    [self setDefaultNavigationBar];
}

@end
